#!/usr/bin/env groovy

def call(String techStack = '') {    
     echo "======================CELAN IMAGE (TECHSTACK:${techStack})============================="
     try
     {
        if ( techStack == 'vue') {
        sh label: 'DOCKER-CLEAN', returnStdout: true, script: 'docker rmi --force `docker images | grep ${DOCKER_NAME}  | awk \'{print $3}\'`'
        
    } else if (techStack == 'springboot') {
        sh label: 'DOCKER-CLEAN', returnStdout: true, script: 'docker rmi --force `docker images |grep ^${HARBOR}/${PROJECT_NAME}/|grep ${VERSION_NUMBER} |awk \'{print $3}\'`'

    } else{
        throw new RuntimeException("NotImplementedException; ${techStack} IS NOT SUPPORT NOW")
     }
 } 
    catch(Exception ex) {
         println("Catching the exception,");
         println(ex.toString());
         println(ex.getMessage());
         println(ex.getStackTrace());  
      }
      echo "===============================CELAN IMAGE DONE=============================="    
}
